package com.upup.train_management.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class WebController {
    
    // 移除 /login 相关映射，避免与 Spring Security 冲突
//     @GetMapping("/login")
//     public String login() {
//         return "login";
//     }
//     
//     @GetMapping("/login.html")
//     public String loginHtml() {
//         return "redirect:/login";
//     }
    
    @GetMapping("/register")
    public String register() {
        return "register";
    }
    
    @GetMapping("/register.html") 
    public String registerHtml() {
        return "redirect:/register";
    }

    // 主页映射
    @GetMapping("/")
    public String home() {
        return "index";
    }

    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @GetMapping("/index.html")
    public String indexHtml() {
        return "redirect:/";
    }

    // 用户页面
    @GetMapping("/user/profile")
    public String userProfile() {
        return "user/profile";
    }

    @GetMapping("/user/tickets")
    public String userTickets() {
        return "user/tickets";
    }

    @GetMapping("/user/booking")
    public String userBooking() {
        return "user/booking";
    }

    // 管理员页面
    @GetMapping("/admin/dashboard")
    public String adminDashboard() {
        return "admin/dashboard";
    }

    @GetMapping("/admin/users")
    public String adminUsers() {
        return "admin/users";
    }

    @GetMapping("/admin/trains")
    public String adminTrains() {
        return "admin/trains";
    }

    @GetMapping("/admin/stations")
    public String adminStations() {
        return "admin/stations";
    }

    @GetMapping("/admin/routes")
    public String adminRoutes() {
        return "admin/routes";
    }

    @GetMapping("/admin/schedules")
    public String adminSchedules() {
        return "admin/schedules";
    }

    @GetMapping("/admin/tickets")
    public String adminTickets() {
        return "admin/tickets";
    }    @GetMapping("/schedule")
    public String schedule() {
        return "schedule";
    }
    
    // 注意：移除了 /login 映射以避免与 Spring Security 冲突    // 新增自定义登录页映射，避免与 Spring Security 默认 /login 冲突
    @GetMapping("/custom-login")
    public String customLogin() {
        return "login";
    }
}